(Quick Reference)

delete

Purpose

Deletes a persistent instance.

Examples

def book = Book.get(1)
book.delete()

Description

The delete method informs the persistence context that a persistent instance should be deleted. Equivalent to the Hibernate delete method.

Calling delete on a transient instance will result in an error

Parameters:

  • flush - If set to true the persistent context will be flushed resulting in the instance being deleted immediately. For example:

def book = Book.get(1)
book.delete(flush: true)